module icache(
	input rst,
	input [31:0] pc,
	output [31:0] inst
);

reg [31:0] _ROM [1023:0];
integer  i;

assign inst=_ROM[pc[11:2]];
initial begin
		$readmemh("E:/Microprocessor/Project/MARS/mips.txt",_ROM);
	end
always@(negedge rst) begin
// R type test
/*	_ROM[0] = 32'h3401_0110;
	_ROM[1] = 32'h3803_0010;
	_ROM[2] = 32'h0023_2024;
	_ROM[3] = 32'h0023_2824;
	_ROM[4] = 32'h0023_3024;
	_ROM[5] = 32'h0023_3824;
	_ROM[6] = 32'h3c01_0000;
	_ROM[7] = 32'h3421_ffff;
	_ROM[8] = 32'h0021_1020;
	_ROM[9] = 32'h2028_0e00;
	_ROM[10] = 32'h3c01_0000;
	_ROM[11] = 32'h3421_ffff;
	_ROM[12] = 32'h0021_4821;
	_ROM[13] = 32'h302a_1234;
	_ROM[14] = 32'h3c0b_abcd;
	_ROM[15] = 32'h0085_6025;
	_ROM[16] = 32'h0003_6826;
	_ROM[17] = 32'h0085_7027;
	_ROM[18] = 32'h000e_7900;
	_ROM[19] = 32'h000e_8102;
	_ROM[20] = 32'h3401_abcd;
	_ROM[21] = 32'h3803_a123;
	_ROM[22] = 32'h0061_2024;
	_ROM[23] = 32'h0061_2824;
	_ROM[24] = 32'h0061_3024;
	_ROM[25] = 32'h0061_3824;
*/
//  sw and lw test
/*
    _ROM[0] = 32'h2001_3fff;
	_ROM[1] = 32'h3402_0020;
	_ROM[2] = 32'hac01_0004;
	_ROM[3] = 32'h0020_1025;
	_ROM[4] = 32'h8c45_0064;
	_ROM[5] = 32'h00a1_3020;
	*/
	//branch test, beq,bne,j,jal,jr,and slt
	/*
	_ROM[0] = 32'h3407_abcd;
	_ROM[1] = 32'h2001_0000;
	_ROM[2] = 32'h2002_0008;
	_ROM[3] = 32'h2003_0000;
	_ROM[4] = 32'h2021_0001;
	_ROM[5] = 32'h0c00_000c;
	_ROM[6] = 32'h20a5_0001;
	_ROM[7] = 32'h1041_0001;
	_ROM[8] = 32'h0800_0004;
	_ROM[9] = 32'h0023_302a;
	_ROM[10] = 32'h14c3_fff5;
	_ROM[11] = 32'h3807_1234;
	_ROM[12] = 32'h0023_1820;
	_ROM[13] = 32'h03e0_0008;
	*/
	// KeyExtent
	/*
	_ROM[0] = 32'h3415010e;
	_ROM[1] = 32'h22b6002b;
	_ROM[2] = 32'h8ea10000;
	_ROM[3] = 32'h22b50001;
	_ROM[4] = 32'h8ea20000;
	_ROM[5] = 32'h22b50001;
	_ROM[6] = 32'h8ea30000;
	_ROM[7] = 32'h22b50001;
	_ROM[8] = 32'h8ea40000;
	_ROM[9] = 32'h34140140;
	_ROM[10] = 32'h0c00001a;
	_ROM[11] = 32'h00000000;
	_ROM[12] = 32'h22b40001;
	_ROM[13] = 32'h00250826;
	_ROM[14] = 32'h00461026;
	_ROM[15] = 32'h00671826;
	_ROM[16] = 32'h00882026;
	_ROM[17] = 32'h22b50001;
	_ROM[18] = 32'haea10000;
	_ROM[19] = 32'h22b50001;
	_ROM[20] = 32'haea20000;
	_ROM[21] = 32'h22b50001;
	_ROM[22] = 32'haea30000;
	_ROM[23] = 32'h22b50001;
	_ROM[24] = 32'haea40000;
	_ROM[25] = 32'h16b6fff0;
	_ROM[26] = 32'h00042e02;
	_ROM[27] = 32'h30a500ff;
	_ROM[28] = 32'h8ca60000;
	_ROM[29] = 32'h00042c02;
	_ROM[30] = 32'h30a500ff;
	_ROM[31] = 32'h8ca70000;
	_ROM[32] = 32'h00042a02;
	_ROM[33] = 32'h30a500ff;
	_ROM[34] = 32'h8ca80000;
	_ROM[35] = 32'h308500ff;
	_ROM[36] = 32'h8ca90000;
	_ROM[37] = 32'h00075600;
	_ROM[38] = 32'h00085c00;
	_ROM[39] = 32'h00086200;
	_ROM[40] = 32'h00ca6825;
	_ROM[41] = 32'h016c7025;
	_ROM[42] = 32'h01ae7825;
	_ROM[43] = 32'h8e900000;
	_ROM[44] = 32'h01f02826;
	_ROM[45] = 32'h03e00008;
	*/
	/*
	initial begin
		$readmemh("E:/Microprocessor/Project/MARS/key_extent.txt",_ROM);
	end
	*/
	/*
	for(i=46;i<1024;i=i+1)begin
		_ROM[i] <= 32'b0;
	end
	*/
end  
endmodule
